package cn.estore.util;

import java.sql.*;

public class DBConnection {
    private String dbDriver = "com.mysql.cj.jdbc.Driver";
    // URL for connecting to the database
    private String url = "jdbc:mysql://localhost:3306/e-store-temp?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC";
    // Create a connection object to the database
    public Connection connection = null;

    public DBConnection() {
       try {
            //加载数据库驱动
            Class.forName(dbDriver).newInstance();
            //连接数据库
            connection = DriverManager.getConnection(url, "root", "123456");
        } catch (Exception e) {
            System.out.println("数据库加载失败");
        }
    }


}
